﻿<UserControl x:Class="Adalbertus.BudgetPlanner.Views.ExpenseTypes.ExpenseTypesView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"             
             xmlns:cal="http://www.caliburnproject.org"
             xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" 
>
    <DockPanel LastChildFill="True">
        <WrapPanel DockPanel.Dock="Top">
            <Label>Nazwa</Label>
            <TextBox Text="{Binding NewExpenseTypeName, UpdateSourceTrigger=PropertyChanged}" Width="100" />

            <Label>Opis</Label>
            <TextBox Text="{Binding NewExpenseTypeDescription}" Width="100"/>

            <Button Content="Wstaw" cal:Message.Attach="[Event Click] = [Action AddNewExpenseType()]"/>
        </WrapPanel>

        <GroupBox Header="Kategorie wydatków">
            <DataGrid ItemsSource="{Binding ExpenseTypes}" AutoGenerateColumns="False"> 
                <DataGrid.Columns>
                    <DataGridTemplateColumn Header="Nazwa">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding Name}" IsReadOnly="{Binding IsReadOnly}" />
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTemplateColumn Header="Opis">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding Description}" IsReadOnly="{Binding IsReadOnly}" />
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTemplateColumn>
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Button Content="Usuń" cal:Message.Attach="[Event Click] = [Action DeleteExpenseType($dataContext)]"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>
            </DataGrid>
        </GroupBox>
    </DockPanel>
</UserControl>
